package com.study.consumer.controller;

import com.study.consumer.service.UserInfoAccess;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * @author anner
 * @description: TODO
 * @date 2021/4/18 21:52
 */
@RestController
@Slf4j
public class NacosAcceptController {

    @Autowired
    private RestTemplate restTemplate;

    @Autowired
    private UserInfoAccess userInfoAccess;

    /**
     * 获取用户信息 异步微服务
     * @return
     */
    @GetMapping("/consumer")
    public String test1() {
        log.info("api 消费者服务访问...");
        Object userInfoDemo = userInfoAccess.getUserInfoDemo();
        log.info("userInfoDemo {}", userInfoDemo);
        return restTemplate.getForObject("http://demo-provider/saveUserValue", String.class);
    }

}
